package com.dlc.apk.api

import com.dlc.apk.api.entity.*
import com.dlc.apk.utils.CacheHelper
import com.dlc.apk.utils.DeviceUtil
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*

/**
 * @author We
 */
interface IServerApi {
    @POST("/form")
    @FormUrlEncoded
    fun getCall(@Field("userName") userName: String?): Call<ResponseBody?>?

    @POST("/upload")
    @Multipart
    fun upload(@Part("name") name: RequestBody?, @Part file: MultipartBody.Part?): Call<ResponseBody?>

    @FormUrlEncoded
    @POST("/test02")
    fun getTestList(@FieldMap params: HashMap<String?, String?>?): Observable<BaseResponseModel<Any?>?>


    //上传日志到服务器
    @POST(ApiConstants.uploadLogUrl)
    @Multipart
    fun uploadLog(
        @PartMap params: HashMap<String, RequestBody>,
        @Part file: MultipartBody.Part?
    ): Observable<BaseResponseModel<Any?>>

    /**
     * 获取设备信息
     */
    @POST("/wxsite/device/api")
    @FormUrlEncoded
    fun deviceInfo(
        @Field("deviceNo") macno: String? = DeviceUtil.androidId
    ): Observable<BaseResponseModel<DeviceInfoResponseData>>

    /**
     * 获取最新apk版本
     */
    @POST("/wxsite/device/api")
    @FormUrlEncoded
    fun getAppVersion(
        @Field("api_name") api_name: String = "getVersion",
        @Field("macno") macno: String? = DeviceUtil.androidId,
    ): Observable<BaseResponseModel<AppVersionResponseData>>

    @POST("/wxsite/device/api")
    @FormUrlEncoded
    fun getAdList(
        @Field("api_name") api_name: String = "getDeviceAdv",
        @Field("macno") macno: String? = DeviceUtil.androidId,
    ): Observable<BaseResponseModel<List<AdData>>>

    /**
     * 运维登录
     */
    @POST("/wxsite/device/api")
    @FormUrlEncoded
    fun login(
        @Field("api_name") api_name: String = "login",
        @Field("mobile") phone: String?,
        @Field("password") password: String?,
    ): Observable<BaseResponseModel<StaffLoginResponseData>>
}